﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using AnguaRPGEngine.DND4eModule.Controls;
using AnguaRPGEngine.Library.Configuration;
using AnguaRPGEngine.Library.Systems;

namespace AnguaRPGEngine.DND4eModule.Forms
{
    public partial class PCPlayerForm : Form
    {
        private Rectangle _ParentRect = new Rectangle();
        private DNDPlayerCharacter _Character;
        public PCPlayerForm(DNDPlayerCharacter character, Form parent)
        {
            //_ParentRect = new Rectangle(parent.Left, parent.Top, parent.Width, parent.Height);
            InitializeComponent();
        }
        private void PCPlayerForm_Load(object sender, EventArgs e)
        {
            cboRace.Items.Clear();
            List<string> races = CharacterRace.AvailableRaces;
            foreach( string race in races )
            {
                cboRace.Items.Add( race );
            }
            cboClass.Items.Clear();
            List<string> classes = CharacterClass.AvailableClasses;
            foreach( string cclass in classes )
            {
                cboClass.Items.Add( cclass );
            }
           /* FormPosition fp = null;
            try
            {
                fp = GameSystem.Instance.ClientConfig.FormPositions.Find(p => p.FormName == this.Name);
            }
            catch
            {
                fp = null;
            }
            if (fp == null)
            {
                this.Left = 0;
                this.Top = _ParentRect.Top + _ParentRect.Height + 30;
                fp = new FormPosition();
                fp.FormName = this.Name;
                fp.Location = this.Location;
                fp.Size = this.Size;
                fp.Visible = this.Visible;
                GameSystem.Instance.ClientConfig.FormPositions.Add(fp);
            }
            else
            {
                this.Location = fp.Location;
                this.Size = fp.Size;
                this.Visible = fp.Visible;
            }
            DisplayCharacter();*/
        }
        private void DisplayCharacter()
        {
            // take the _character and fill in the form (if it is null, then set defaults)
        }

        private void PCPlayerForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!GameSystem.Instance.IsShuttingDown)
            {

                e.Cancel = true;
                this.Visible = false;
            }
            else
            {
                FormPosition fp = null;
                try
                {
                    fp = GameSystem.Instance.ClientConfig.FormPositions.Find(p => p.FormName == this.Name);
                }
                catch
                {
                    fp = null;
                }
                if (fp == null)
                {

                    fp = new FormPosition();
                    fp.FormName = this.Name;
                    fp.Location = this.Location;
                    fp.Size = this.Size;
                    fp.Visible = this.Visible;
                    GameSystem.Instance.ClientConfig.FormPositions.Add(fp);
                }
                else
                {
                    fp.Location = this.Location;
                    fp.Size = this.Size;
                    fp.Visible = this.Visible;
                }
            }
        }
       
       
    }
}
